#include "inttobyte.h"

QByteArray int32ToByte(qint32 value) {
	QByteArray result;
	int typeSize = sizeof(qint32);
	result.resize(typeSize);

	char *c = (char *) &value;

	for(int i = 0; i < typeSize; i++) {
		result[i] = c[i];
	}

	return result;
}

QByteArray uint32ToByte(quint32 value) {
	QByteArray result;
	int typeSize = sizeof(quint32);
	result.resize(typeSize);

	char *c = (char *) &value;

	for(int i = 0; i < typeSize; i++) {
		result[i] = c[i];
	}

	return result;
}

QByteArray int16ToByte(qint16 value) {
	QByteArray result;
	int typeSize = sizeof(qint16);
	result.resize(typeSize);

	char *c = (char *) &value;

	for(int i = 0; i < typeSize; i++) {
		result[i] = c[i];
	}

	return result;
}

QByteArray uint16ToByte(quint16 value) {
	QByteArray result;
	int typeSize = sizeof(quint16);
	result.resize(typeSize);

	char *c = (char *) &value;

	for(int i = 0; i < typeSize; i++) {
		result[i] = c[i];
	}

	return result;
}
